package com.service.biz;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.entity.biz.BizBook;
import com.entity.sys.query.SysQuery;
import com.github.pagehelper.PageInfo;
import com.mapper.biz.BizBookMapper;
import com.common.base.BaseService;
import org.springframework.stereotype.Service;

/**
 * 书籍 服务实现类
 */
@Service
public class BizBookService extends BaseService<BizBookMapper, BizBook> {

    /**
     * 列表
     */
    public PageInfo<BizBook> page(SysQuery query){
        QueryWrapper<BizBook> queryWrapper = new QueryWrapper<>();
        if (StrUtil.isNotBlank(query.getName())){
            queryWrapper.like("name",query.getName());
        }
        if (StrUtil.isNotBlank(query.getCode())){
            queryWrapper.eq("category",query.getCode());
        }
        String apply = queryApplyScope("dept", null,2);
        if (StrUtil.isNotBlank(apply)){
            queryWrapper.apply(apply);
        }
        return new PageInfo<>(baseMapper.selectList(queryWrapper));
    }

}
